<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="id" label="id" />
        <el-table-column prop="ip" label="ip" />
        <el-table-column prop="content" :label="$t('plc.content')" />
        <el-table-column prop="plcStatus" :label="$t('plc.plcStatus')" />
        <el-table-column prop="hasPallet" :label="$t('plc.hasPallet')" />
        <el-table-column prop="createBy" :label="$t('plc.createBy')" />
        <el-table-column prop="createTime" :label="$t('plc.createTime')" />
        <el-table-column prop="updateBy" :label="$t('plc.updateBy')" />
        <el-table-column prop="updateTime" :label="$t('plc.updateTime')" />
        <el-table-column v-if="checkPer(['admin','plcOutBound:edit','plcOutBound:del'])" :label="$t('common.operation')" width="150px" align="center">
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
              :permission="permission"
            />
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudPlcOutBound from '@/api/plcOutBound'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'

const defaultForm = { id: null, ip: null, content: null, plcStatus: null, hasPallet: null, createBy: null, createTime: null, updateBy: null, updateTime: null }
export default {
  name: 'PlcOutBound',
  components: { pagination, crudOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  cruds() {
    return CRUD({ title: '出库口plc', url: 'api/plcOutBound', idField: 'id', sort: 'id,desc', crudMethod: { ...crudPlcOutBound }})
  },
  data() {
    return {
      permission: {
        add: ['admin', 'plcOutBound:add'],
        edit: ['admin', 'plcOutBound:edit'],
        del: ['admin', 'plcOutBound:del']
      },
      rules: {
      }}
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>

<style scoped>

</style>
